<%@ page import="com.auctionhaus.Customer" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'customer.label', default: 'Customer')}" />
        <title>My Listings</title>
    </head>
    <body>
       <div class="body">
        <g:set var="currentListings" value="${message(code: 'listings.label', default: 'Listings')}" />
        <br><h1>Current Listings for ${customerInstance.getLoginName()}</h1><br/>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                            <g:sortableColumn property="id" title="${message(code: 'listing.id.label', default: 'Id')}" />
                            <g:sortableColumn property="listName" title="${message(code: 'listing.listName.label', default: 'List Name')}" />
                            <g:sortableColumn property="creationDate" title="${message(code: 'listing.creationDate.label', default: 'Creation Date')}" />
                            <g:sortableColumn property="description" title="${message(code: 'listing.description.label', default: 'Description')}" />
                            <g:sortableColumn property="startBidPrice" title="${message(code: 'listing.startBidPrice.label', default: 'Starting Bid Price')}" />
                            <g:sortableColumn property="endDateTime" title="${message(code: 'listing.endDateTime.label', default: 'End Date Time')}" />
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${customerInstance.listings}" status="i" var="listingInstance">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                            <td valign="top" class="value">${fieldValue(bean: listingInstance, field: "id")}</td>
                            <td><g:link controller="listing" action="show" id="${listingInstance.id}">${fieldValue(bean: listingInstance, field: "listName")}</g:link></td>
                            <td valign="top" class="value">${fieldValue(bean: listingInstance, field: "creationDate")}</td>
                            <td valign="top" class="value">${fieldValue(bean: listingInstance, field: "description")}</td>
                            <td valign="top" class="value"><g:formatNumber number="${listingInstance.startBidPrice}" type="currency" currencyCode="USD" /></td>
                            <td valign="top" class="value">${fieldValue(bean: listingInstance, field: "endDateTime")}</td>
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${customerInstanceListingTotal}" />
            </div>
        </div>
    </body>
</html>
